package net.wofly.sale.order.service;

import net.wofly.common.persistence.PageWrapper;
import net.wofly.framework.util.ReturnBean;
import net.wofly.sale.order.domain.ReturnSales;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface IReturnSalesService {
    
    /**
     * 增加或修改
     *
     * @param entity
     * @return
     */
    public ReturnSales save(ReturnSales entity);
    
    /**
     * 删除
     *
     * @param entity
     * @return
     */
    public void delete(ReturnSales entity);
    
    /**
     * 根据主键ID删除
     *
     * @param key
     * @return
     */
    public void delete(String key);
    
    /**
     * 根据主键查询
     *
     * @param key
     * @return
     */
    public ReturnSales findOne(String key);
    
    Page<ReturnSales> findAll(Specification specification, Pageable pageable);
    
    public List<ReturnSales> save(List<ReturnSales> entityList);
    
    Integer countByOrderIDAndStatusNotIn(String orderID, List<Integer> statusList);
    
    Object findMaxReturnSalesNONoByDate(@Param(value = "dateStr") String dateStr);
    
    public ReturnSales transReturnSales(ReturnSales returnSales);
    
    public ReturnSales findByProcessInsID(String processInsID);
    
    public List<ReturnSales> findByProcessInsIDIn(List<String> processInsIDs);
    
    public String generateReturnSalesNO();

    void translateReturnSalesInfo(ReturnSales returnSales);
    
    /**
     * 退货-根据订单ID查询可退货内容
     *
     * @param orderID
     * @return
     */
    ReturnBean<ReturnSales> getBackGoodsForReturnSales(String orderID);
    
    /**
     * 预计算退货商品及赠品数量
     *
     * @param orderID
     * @param returnSales
     * @return
     */
    ReturnBean<ReturnSales> preCalcReturnSales(String orderID, ReturnSales returnSales);
    
    /**
     * 保存退货信息
     *
     * @param orderID
     * @param returnSales
     * @return
     */
    ReturnBean<ReturnSales> saveReturnSales(String orderID, ReturnSales returnSales);
    
    /**
     * 编辑并保存退货信息
     *
     * @param returnSales
     * @return
     */
    ReturnBean<ReturnSales> editAndSaveReturnSales(ReturnSales returnSales);
    
    /**
     * 退货详情
     *
     * @param returnSalesID
     * @return
     */
    ReturnBean<ReturnSales> getReturnSales(String returnSalesID);
    
    /**
     * 删除退货
     *
     * @param returnSalesID
     * @return
     */
    ReturnBean<ReturnSales> deleteReturnSales(String returnSalesID);
    
    /**
     * 取消退货
     *
     * @param returnSalesID
     * @return
     */
    ReturnBean<ReturnSales> cancelReturnSales(String returnSalesID);
    
    /**
     * 退货列表查询
     *
     * @param returnSalesNo
     * @param returner
     * @param customerName
     * @param status
     * @param pageNum
     * @param pageSize
     * @return
     */
    ReturnBean<PageWrapper<ReturnSales>> getReturnSalesByCnd(
            String returner, String returnSalesNo, String customerName, Integer status, Long startTime, Long endTime,
            Integer pageNum, Integer pageSize);
    
    /**
     * 退货入库
     *
     * @param returnSalesID
     * @return
     */
    ReturnBean<String> addReturnSalesInStock(String returnSalesID);
}
